package com.ypinkj.app.config;

import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import org.apache.ibatis.reflection.MetaObject;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * @author LF
 * @date 2020/9/24 - 14:44
 * 新增和更新时自动填充时间
 */
@Component
public class MyDetaObjectHander implements MetaObjectHandler {

    //新增时自动参数
    @Override
    public void insertFill(MetaObject metaObject) {
        this.setFieldValByName("createTime",new Date(),metaObject);
        this.setFieldValByName("updateTime",new Date(),metaObject);
        this.setFieldValByName("delFlag","0",metaObject);
        this.setFieldValByName("isApply","0",metaObject);
        this.setFieldValByName("isDownload","0",metaObject);
    }

    //更新时自动参数
    @Override
    public void updateFill(MetaObject metaObject) {
        this.setFieldValByName("updateTime",new Date(),metaObject);

    }

}
